#
# # 财务
# # 添加应付款02
# 客户名称为英文
# # 财务
# # 添加应付款01
# 客户名称为中文
# from selenium import webdriver # 调用webdriver
# from selenium.webdriver.common.by import By # 引入by模块
# from time import sleep # 调用sleep
# from selenium.webdriver.support.select import Select
# driver = webdriver.Chrome() #打开浏览器
# try:
#     driver.maximize_window()  # 最大化浏览器
#     driver.get("http://192.168.1.79/") # 访问crm后台
#     cookie={"name":"PHPSESSID",'value': 'p5tsh1p53643ic9ld0la870gm5'}
#     driver.add_cookie(cookie)
#     driver.get("http://192.168.1.79/crm/index.php?m=finance&a=add&t=payables")  # 访问crm添加产品页面
#     #定位器
#     # btn_locator=(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[3]/a[1]') #添加应付款
#     yf_name_locator=(By.XPATH,"/html/body/div[5]/div[2]/div/form/table/tbody/tr[2]/td[2]/input")#应付款名
#     contract_name_locator=(By.ID,"contract_name")#合同
#     contract_locator=(By.CSS_SELECTOR,"#data > tr > td:nth-child(1) > input[type=radio]")
#     ui_locator=(By.XPATH,"/html/body/div[8]/div[3]/div/button[1]") #合同ok按钮
#     pay_time_locator=(By.ID,"pay_time")#付款时间
#     description_locator=(By.XPATH,"/html/body/div[5]/div[2]/div/form/table/tbody/tr[9]/td[2]/textarea")#付款时间
#     sk_submit_locator=(By.NAME,"submit")
#     #查找应收元素
#     ys_name_element = driver.find_element(*yf_name_locator).send_keys("cant")#查找应付款元素
#     sleep(2)
#     contract_name_element=driver.find_element(*contract_name_locator).click() #查看合同元素，并点击
#     sleep(2)
#     contract_element=driver.find_element(*contract_locator).click()
#     sleep(2)
#     ui_element=driver.find_element(*ui_locator).click() #查看ok元素，并点击
#     sleep(2)
#     pay_time_element=driver.find_element(*pay_time_locator) #查看付款时间
#     pay_time_element.clear()#清除文本
#     pay_time_element.send_keys("2022-09-22") #输入时间
#     sleep(2)
#     driver.find_element(*description_locator).send_keys("项目最终决定按原来计划实施")#查找描述内容元素，并输入内容
#     sleep(2)
#     driver.find_element(*sk_submit_locator).click() #查找保存元素，并点击按钮
# except:
#     raise
# finally:
#     sleep(5) # 暂停五秒，并关闭浏览器
#     driver.quit()
